import java.util.*;

class TreeNode {

        public char val;

        public TreeNode left;

        public TreeNode right;

        

        public TreeNode(char val) {

            this.val = val;

        }

}



public class Main {

    public static int i = 0;

    public static TreeNode CreateBinaryTree(String str) {

        if(str==null) {

            return null;

        }

        TreeNode root = new TreeNode(str.charAt(i));

        i++;

        if(root.val!='#') {

            if(root.left==null) {

                root.left = CreateBinaryTree(str);

             }

             if(root.right==null) {

                root.right =CreateBinaryTree(str);

             }

        }

        return root;

    }

    public static void inOrder(TreeNode root) {

        if(null == root) {

            return;

        }

        inOrder(root.left);

        if(root.val!='#') {

            System.out.print(root.val+" ");

        }

        inOrder(root.right);

    }

    public static void main(String args[]) {

        Scanner scanner = new Scanner(System.in);

        while(scanner.hasNextLine()) {

            String s = scanner.nextLine();

            TreeNode treenode = CreateBinaryTree(s);

            inOrder(treenode);

        }

}

}



